import Mock from 'mockjs'
import { baseURL } from '@/config'

// 贷款审批列表
Mock.mock(new RegExp(baseURL + '/loan/approval/list'), 'get', {
  code: 200,
  msg: 'success',
  'data|10': [{
    'id|+1': 1,
    'applyNo': /LN@date("yyyyMMdd")@string("number", 4)/,
    'customerName': '@cname',
    'loanAmount|10000-1000000': 1,
    'loanTerm|12-36': 1,
    'loanPurpose|1': ['经营周转', '设备购置', '技术改造', '其他'],
    'applyTime': '@datetime',
    'currentNode|1': ['初审', '复审', '终审'],
    'status|1': ['待审核', '审核中', '通过', '拒绝'],
    'urgentLevel|1': ['普通', '加急'],
    'remark': '@cparagraph(1)'
  }],
  total: 100
})

// 贷款审批详情
Mock.mock(new RegExp(baseURL + '/loan/approval/detail'), 'get', {
  code: 200,
  msg: 'success',
  data: {
    basic: {
      'applyNo': /LN@date("yyyyMMdd")@string("number", 4)/,
      'customerName': '@cname',
      'idNo': /[1-9]\d{5}(19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dX]/,
      'mobile': /1[3-9]\d{9}/,
      'loanAmount|10000-1000000': 1,
      'loanTerm|12-36': 1,
      'loanPurpose|1': ['经营周转', '设备购置', '技术改造', '其他'],
      'repayMethod|1': ['等额本息', '等额本金', '先息后本', '一次性还本付息'],
      'guaranteeMethod|1': ['信用', '保证', '抵押', '质押'],
      'applyTime': '@datetime'
    },
    materials: [{
      'id|+1': 1,
      'fileName': '@ctitle(5,10).pdf',
      'fileType|1': ['身份证', '收入证明', '其他'],
      'fileSize|1-10000': 1,
      'uploadTime': '@datetime'
    }],
    approvalHistory: [{
      'id|+1': 1,
      'nodeName|1': ['初审', '复审', '终审'],
      'approver': '@cname',
      'approvalType|1': ['通过', '拒绝', '退回'],
      'approvalOpinion': '@cparagraph(1)',
      'approvalTime': '@datetime'
    }]
  }
})

// 放款审批列表
Mock.mock(new RegExp(baseURL + '/lending/approval/list'), 'get', {
  code: 200,
  msg: 'success',
  'data|10': [{
    'id|+1': 1,
    'contractNo': /HT@date("yyyyMMdd")@string("number", 4)/,
    'customerName': '@cname',
    'loanAmount|10000-1000000': 1,
    'approvedAmount|10000-1000000': 1,
    'loanTerm|12-36': 1,
    'applyTime': '@datetime',
    'status|1': ['待审核', '审核中', '通过', '拒绝'],
    'urgentLevel|1': ['普通', '加急'],
    'remark': '@cparagraph(1)'
  }],
  total: 100
})

// 放款审批详情
Mock.mock(new RegExp(baseURL + '/lending/approval/detail'), 'get', {
  code: 200,
  msg: 'success',
  data: {
    basic: {
      'contractNo': /HT@date("yyyyMMdd")@string("number", 4)/,
      'customerName': '@cname',
      'idNo': /[1-9]\d{5}(19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dX]/,
      'mobile': /1[3-9]\d{9}/,
      'loanAmount|10000-1000000': 1,
      'approvedAmount|10000-1000000': 1,
      'loanTerm|12-36': 1,
      'interestRate|1-10.2': 1,
      'repayMethod|1': ['等额本息', '等额本金', '先息后本', '一次性还本付息'],
      'signDate': '@date',
      'startDate': '@date',
      'endDate': '@date'
    },
    bankInfo: {
      'bankName': '@ctitle(3,5)银行',
      'bankBranch': '@city支行',
      'accountName': '@cname',
      'accountNo': /\d{16,19}/,
      'reservedMobile': /1[3-9]\d{9}/
    },
    approvalHistory: [{
      'id|+1': 1,
      'approver': '@cname',
      'approvalType|1': ['通过', '拒绝', '退回'],
      'approvalOpinion': '@cparagraph(1)',
      'approvalTime': '@datetime'
    }]
  }
})

// 提交审批
Mock.mock(new RegExp(baseURL + '/loan/approval/submit'), 'post', {
  code: 200,
  msg: 'success',
  data: null
})

Mock.mock(new RegExp(baseURL + '/lending/approval/submit'), 'post', {
  code: 200,
  msg: 'success',
  data: null
}) 